﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Rung.Net.Enums;

namespace Rung.Net.Events
{
    public delegate void NetConnectedEventHandler(object sender, NetConnectedEventArgs e);
    public class NetConnectedEventArgs : EventArgs
    {

    }

    public delegate void NetDisconnectedEventHandler(object sender, NetDisconnectedEventArgs e);
    public class NetDisconnectedEventArgs : EventArgs
    {
        /// <summary>
        /// The reason why the client was stopped.
        /// </summary>
        public NetStoppedReason Reason { get; private set; }

        public NetDisconnectedEventArgs(NetStoppedReason reason)
        {
            Reason = reason;
        }
    }

    public delegate void NetReceivedEventHandler<T>(object sender, NetReceivedEventArgs<T> e);
    public class NetReceivedEventArgs<T> : EventArgs
    {
        /// <summary>
        /// The data received.
        /// </summary>
        public T Data { get; private set; }

        public NetReceivedEventArgs(T data)
        {
            Data = data;
        }
    }

    /// <summary>
    /// 传输进度更改事件。
    /// </summary>
    public delegate void CacheProcessChangedEventHandler(object sender, CacheProcessChangedEventArgs e);
    public class CacheProcessChangedEventArgs : EventArgs
    {
        /// <summary>
        /// 总包数。
        /// </summary>
        public int PackageCountTotal { get; protected set; }

        /// <summary>
        /// 当前索引数。
        /// </summary>
        public int Index { get; protected set; }

        /// <summary>
        /// 已接受的总包数。
        /// </summary>
        public int PackageCountReceived { get; protected set; }

        public CacheProcessChangedEventArgs(int index, int total, int received)
        {
            Index = index;
            PackageCountTotal = total;
            PackageCountReceived = received;
        }
    }
}
